package cn.pping.basic.interceptor.config;

import cn.pping.basic.interceptor.LoginInterceptor;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

// 配置类
@Configuration
public class MyConfig implements WebMvcConfigurer {


    @Autowired
    private LoginInterceptor loginInterceptor;

    @Override
    public void addInterceptors(InterceptorRegistry registry) {
        registry.addInterceptor(loginInterceptor) // 使用的拦截器
                .addPathPatterns("/**") // 拦截路径
                .excludePathPatterns("/fastDfs/**") // 放行路径
                .excludePathPatterns("/login/**")// 放行路径
                .excludePathPatterns("/verifyCode/**")// 放行路径
                .excludePathPatterns("/shop/settlement")// 放行路径
                .excludePathPatterns("/swagger-resources/**", "/webjars/**",
                        "/v2/**", "/swagger-ui.html/**");// 放行路径
    }

}
